#ifndef FULL_SCREEN_TRIANGLE
    #define FULL_SCREEN_TRIANGLE

    float2 TransformFullScreenTriangleVertexToUV(float2 vertex)
    {
        float2 uv = (vertex + 1.0) * 0.5;
        #if UNITY_UV_STARTS_AT_TOP
            uv.y = 1 - uv.y; 
        #endif
        return uv;
    }

    float4 TransformFullScreenTriangleVertexToClip(float2 vertex)
    {
        return float4(vertex, 0.0, 1.0);
    }
    
    // float3 GetWorldPositionFromDepthValue(float2 uv, float depth) 
    // {
        //     float camPosZ = _ProjectionParams.y + (_ProjectionParams.z - _ProjectionParams.y) * depth;

        //     float height = 2 * camPosZ / unity_CameraProjection._m11;
        //     float width = _ScreenParams.x / _ScreenParams.y * height;

        //     float camPosX = width * uv.x - width * 0.5;
        //     float camPosY = height * uv.y - height * 0.5;
        //     float4 camPos = float4(camPosX, camPosY, camPosZ, 1.0);
        //     return mul(unity_CameraToWorld, camPos).xyz;
    // }


    #define INIT_FULL_SCREEN_TRIANGLE_VERTEX(vertex,uv,clipUv) uv = TransformFullScreenTriangleVertexToUV(vertex.xy); clipUv = TransformFullScreenTriangleVertexToClip(vertex.xy);

    
    #if defined(_FULL_SCREEN_TRIANGLE_IMAGE)
        #define FragmentInput v2f_img

        struct appdata_img
        {
            float4 vertex : POSITION;
        };
        struct v2f_img
        {
            float4 pos : SV_POSITION;   //顶点位置  
            float2 uv  : TEXCOORD0;     //纹理坐标 
        };
        v2f_img vert_img(appdata_img v)
        {
            v2f_img o;
            // o.pos = TransformFullScreenTriangleVertexToClip(v.vertex.xy);
            // o.uv = TransformFullScreenTriangleVertexToUV(v.vertex.xy);
            INIT_FULL_SCREEN_TRIANGLE_VERTEX(v.vertex,o.uv,o.pos)
            return o;
        }

    #endif

#endif